class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        int m = array.size();
        int n = array[0].size();
        if(m == 0 || n == 0) return false;
        int i = 0, j = n - 1;
        while(i <= m - 1 && j >= 0) {
            if(array[i][j] == target) return true;
            if(array[i][j] > target) j--;
            else i++;
        }
        return false;
    }
};